package javacommon.base;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javacommon.util.FileUtil;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.mvc.UrlFilenameViewController;

import com.google.gson.Gson;
import com.smg.community.model.City;
import com.smg.community.model.CrmUser;
import com.smg.community.model.ExtJsPageData;
import com.smg.community.model.SmgIndexTopFiveimages;
import com.smg.community.service.CityManager;
import com.smg.community.service.CrmRightManager;
import com.smg.community.service.CrmRoleManager;
import com.smg.community.service.CrmRoleRightManager;
import com.smg.community.service.CrmUserManager;
import com.smg.community.service.SmgAndroidVersionManager;
import com.smg.community.service.SmgAppSuggestionManager;
import com.smg.community.service.SmgCarBrandManager;
import com.smg.community.service.SmgCarModelsManager;
import com.smg.community.service.SmgGroupManager;
import com.smg.community.service.SmgIndexRightbottomImageManager;
import com.smg.community.service.SmgIndexTopFiveimagesManager;
import com.smg.community.service.SmgKeywordManager;
import com.smg.community.service.SmgMemberBehaviorCommentManager;
import com.smg.community.service.SmgMemberBehaviorManager;
import com.smg.community.service.SmgMemberCoorManager;
import com.smg.community.service.SmgMemberFocusManager;
import com.smg.community.service.SmgMemberFriendManager;
import com.smg.community.service.SmgMemberManager;
import com.smg.community.service.SmgMemberReportManager;
import com.smg.community.service.SmgMessageManager;
import com.smg.community.service.SmgPoiCheckinManager;
import com.smg.community.service.SmgPoiManager;
import com.smg.community.service.SmgRegVerifycodeRecordManager;
import com.smg.community.service.SmgTalkHistoryManager;
import com.smg.community.service.SmgTopicManager;
import com.smg.community.service.TalkService;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author yushengbing
 * 
 * @param <Entity>
 * @param <PK>
 */
/**
 * @author user
 *
 * @param <Entity>
 * @param <PK>
 */
public class BaseRestSpringController<Entity, PK> extends UrlFilenameViewController implements Serializable
{
	
	@Autowired
	public SmgMemberManager smgMemberManager;
	@Autowired
	public SmgMemberBehaviorManager smgMemberBehaviorManager;
	@Autowired
	public SmgPoiManager smgPoiManager;
	@Autowired
	public SmgPoiCheckinManager smgPoiCheckinManager;
	@Autowired
	public SmgMessageManager smgMessageManager;
	@Autowired
	public SmgMemberBehaviorCommentManager smgMemberBehaviorCommentManager;
	@Autowired
	public SmgMemberFocusManager smgMemberFocusManager; 
	@Autowired
	public SmgMemberFriendManager smgMemberFriendManager;
	@Autowired
	public SmgAndroidVersionManager smgAndroidVersionManager;
	@Autowired
	public SmgCarBrandManager smgCarBrandManager ;
	@Autowired
	public SmgCarModelsManager smgCarModelsManager;
	@Autowired
	public SmgRegVerifycodeRecordManager smgRegVerifycodeRecordManager;
	@Autowired
	public SmgAppSuggestionManager smgAppSuggestionManager;
	@Autowired
	public SmgMemberReportManager smgMemberReportManager;
	@Autowired
	public SmgTalkHistoryManager smgTalkHistoryManager;
	@Autowired
	public SmgMemberCoorManager smgMemberCoorManager;
	@Autowired
	public SmgGroupManager smgGroupManager;
	@Autowired
	public SmgTopicManager smgTopicManager;
	
	@Resource(name = "talkService")
	public TalkService talkService;
	
	/**
	 * 
	 */
	static Log logger = LogFactory.getLog(BaseRestSpringController.class);
	private static final long serialVersionUID = 1L;
	
	public static final String recvEncoding = "UTF-8";



//测试地址为： http://218.78.213.131:8080/vipone/intf




//正式地址为：http://218.78.213.131:8018/vipone/intf
	/**
	 * 加载属性文件
	 * 
	 * @param filePath
	 *            文件路径
	 * @return 属性文件
	 */
	public static Properties loadProperties(String filePath)
	{
		
		Properties p = new Properties();
		try
		{
			String suffix = ".properties";
			if (filePath.lastIndexOf(suffix) == -1)
			{
				filePath += suffix;
			}
			p.load(getFileInputStream(filePath));
		} catch (Exception e)
		{
		  e.printStackTrace();
		}
		logger.debug("load config.properties");
		return p;
	}
	
	/**
	 * 根据文件路径获取输入流
	 * 
	 * @param filePath
	 *            文件路径
	 * @return 输入流
	 */
	public static InputStream getFileInputStream(String filePath)
	{
		InputStream fis = null;
		try
		{
			fis = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
		} catch (Exception e)
		{
		}
		return fis;
	}
	
}
